package com.shengwei.truck.driver.view.adapter.task;
import android.content.Context;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import com.shengwei.truck.driver.bean.FileUrlBean;
import com.shengwei.truck.driver.view.ui.task.PhotoViewFragment;
import java.util.List;
/*
 * 任务列表的ViewPager for Fragment
 */
public class PhotoPagerAdapter extends FragmentPagerAdapter {
    private  Context mContext;
    private List<FileUrlBean> mDataList;

    public PhotoPagerAdapter(Context context, FragmentManager supportFragmentManager, List<FileUrlBean> dataList){
        super(supportFragmentManager);
        mContext = context;
        mDataList = dataList;
    }
    @Override
    public int getCount() {
        if(mDataList != null){
            return mDataList.size();
        }
        return 0;
    }
    @Override
    public Fragment getItem(int position) {
        String photoUrl = mDataList.get(position).getFileUrl();
        String thumbUrl = mDataList.get(position).getThumbFileUrl();
        Fragment fragment =  PhotoViewFragment.newInstance(photoUrl,thumbUrl);
        return fragment;
    }
    @Override
    public int getItemPosition(Object object) {
        return super.getItemPosition(object);
    }

}
